Function: extensie

CALL:

fname = extensie(fname, ext)

DESCRIPTION:

Verify extension, append extension if needed

INPUT:

fname any
string, candidate filename
ext any
string, required file extension
LEGACY any
if true:
    Default behavior. Anything after "." is replaced
        extensie('donar.mat','dia')   ==> donar.dia
        extensie('donar.mat','mat')   ==> donar.mat
        extensie('gis.osm.shp','shp') ==> gis.shp
        extensie('gis.osm','shp')     ==> gis.shp

if false:
    New behavior (20171022) if proposed file has extension already
    (or filename containing ".") and extension is different, append
    extension.
        extensie('donar.mat','dia')   ==> donar.mat.dia
        extensie('donar.mat','mat')   ==> donar.mat
        extensie('gis.osm.shp','shp') ==> gis.osm.shp
        extensie('gis.osm','shp')     ==> gis.osm.shp

OUTPUT:

fname any
string, filename including extension

EXAMPLE:

       fname1 = extensie('donar', 'dia')
       fname2 = extensie('donar.dia', 'dia')
  

APPROACH:

     Replace or append extension
  
  AUTHOR:
   Nanne van der Zijpp, ModelIT